<!doctype html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml" xmlns:v-demo="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .router-link-active {
            color:#f00;
        }
        pre {
            font-family: sans-serif;
            font-size: 1em;
            line-height:1.5em;
        }

    </style>
</head>
<body>
<div id="app">
    <counter :xx="xx"></counter>
</div>
</body>

<script src="../../vender/vue@2.4.2.js"></script>
<script src="../../vender/vuex@2.0.0.min.js"></script>
<!--<script src="../vue-router@2.7.0.js"></script>-->

<script>
    const store = new Vuex.Store({
        state: {
            count: 0
        },
        mutations: {
            add(state,n){
                state.count+=n;
            },
            cut(state,n){
                state.count-=n;
            },
            incr(state,payload) {
                state.count+=payload.amount;
            },
            decr(state,payload) {
                state.count-=payload.amount;
            }
        }
    });
    store.commit('add',10);
    console.log(store.state.count);

    store.commit('cut',5);
    console.log(store.state.count);


    store.commit('incr',{amount:10});
    console.log(store.state.count);

    store.commit('decr',{amount:5});
    console.log(store.state.count);

</script>
</html>